home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / IEditor / IO.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-17  |  32.6 KB  |  1,434 lines

  1. /// Include
  2. #include <stdarg.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6.  
  7.  
  8. #define INTUI_V36_NAMES_ONLY
  9. #define CATCOMP_NUMBERS
  10.  
  11. #include <exec/nodes.h>                 // exec
  12. #include <exec/lists.h>
  13. #include <exec/memory.h>
  14. #include <exec/types.h>
  15. #include <dos/dos.h>                    // dos
  16. #include <workbench/workbench.h>        // workbench
  17. #include <workbench/icon.h>
  18. #include <libraries/gadtools.h>         // libraries
  19. #include <libraries/reqtools.h>
  20. #include <libraries/locale.h>
  21. #include <clib/exec_protos.h>           // protos
  22. #include <clib/intuition_protos.h>
  23. #include <clib/dos_protos.h>
  24. #include <clib/locale_protos.h>
  25. #include <clib/icon_protos.h>
  26. #include <clib/reqtools_protos.h>
  27. #include <pragmas/exec_pragmas.h>       // pragmas
  28. #include <pragmas/intuition_pragmas.h>
  29. #include <pragmas/graphics_pragmas.h>
  30. #include <pragmas/dos_pragmas.h>
  31. #include <pragmas/locale_pragmas.h>
  32. #include <pragmas/icon_pragmas.h>
  33. #include <pragmas/reqtools_pragmas.h>
  34.  
  35.  
  36. #include "DEV_IE:defs.h"
  37. #include "DEV_IE:Include/loaderlib.h"
  38. #include "DEV_IE:Include/loader_pragmas.h"
  39. #include "DEV_IE:Include/expander_pragmas.h"
  40. #include "DEV_IE:GUI.h"
  41. #include "DEV_IE:GUI_locale.h"
  42. ///
  43. /// Prototipi
  44. static void     PutString2( STRPTR );
  45. static void     WriteMainProc( void );
  46. static void     WriteARexx( void );
  47. static void     WriteMenus( struct WindowInfo * );
  48. static void     SistemaImg( void );
  49. static void     WriteImg( void );
  50. static void     WriteITexts( struct WindowInfo * );
  51. static void     WriteImages( struct WindowInfo * );
  52. static void     WriteBoxes( struct WindowInfo * );
  53. static struct WindowInfo *LoadWin( void );
  54. static void     WriteWin( struct WindowInfo * );
  55. static void     WriteGad( struct GadgetInfo * );
  56. static void     WriteBool( struct BooleanInfo * );
  57. static void     WriteLocaleStuff( void );
  58. ///
  59. /// Dati
  60. UBYTE   RawDataPattern[]    = "#?.gui";
  61. UBYTE   FinestraPattern[]   = "#?.wnd";
  62. UBYTE   GadgetPattern[]     = "#?.gad";
  63.  
  64. UBYTE   GUI_ext[]           = "gui";
  65. UBYTE   WND_ext[]           = "wnd";
  66. UBYTE   GAD_ext[]           = "gad";
  67.  
  68. struct Library     *LoaderBase;
  69. ///
  70. /// Icona progetto
  71. UWORD gr_data[] = {
  72.  
  73.     /* plane 0 */
  74.  
  75.     0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 
  76.     0x0000, 0x0000, 0x0000, 0x0000, 0x0030, 
  77.     0x0000, 0x0000, 0x0003, 0x0030, 0x0030, 
  78.     0x0000, 0x0000, 0x0002, 0x8030, 0x0030, 
  79.     0x0000, 0x0000, 0x0003, 0x4030, 0x0030, 
  80.     0x03ff, 0xffff, 0xffe2, 0xa030, 0x0030, 
  81.     0x03aa, 0xaaaa, 0xaae3, 0x5031, 0xfc30, 
  82.     0x0200, 0x0000, 0x0062, 0xa831, 0x8030, 
  83.     0x0200, 0x0000, 0x0063, 0x5401, 0xe030, 
  84.     0x0200, 0x0000, 0x0062, 0xaa01, 0x8030, 
  85.     0x0200, 0x0155, 0x4063, 0x7501, 0x8030, 
  86.     0x0200, 0x2100, 0x0062, 0xaa81, 0xfc30, 
  87.     0x0200, 0x2100, 0x0063, 0x6540, 0x0030, 
  88.     0x0200, 0x2100, 0x0062, 0xa2a0, 0x0030, 
  89.     0x0200, 0x2100, 0x4063, 0x6150, 0x0030, 
  90.     0x0200, 0x2100, 0x4062, 0xa0a8, 0x0030, 
  91.     0x0255, 0x6001, 0xf063, 0x6054, 0x0030, 
  92.     0x0200, 0x0000, 0x4062, 0xa02a, 0x0030, 
  93.     0x0200, 0x0000, 0x4063, 0x6015, 0x0030, 
  94.     0x0200, 0x0000, 0x0062, 0xbffa, 0x8030, 
  95.     0x02aa, 0xaaaa, 0xaaa3, 0x5555, 0x4030, 
  96.     0x0000, 0x0000, 0x0002, 0xaaaa, 0xa030, 
  97.     0x0000, 0x0000, 0x0003, 0xffff, 0xf030, 
  98.     0x0000, 0x0000, 0x0000, 0x0000, 0x0030, 
  99.     0x7fff, 0xffff, 0xffff, 0xffff, 0xfff0, 
  100.  
  101.     /* plane 1 */
  102.  
  103.     0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 
  104.     0xeaaa, 0xaaaa, 0xaaaa, 0xaaaa, 0xaa80, 
  105.     0xeaaa, 0xaaaa, 0xaaa8, 0xaa8a, 0xaa80, 
  106.     0xeaaa, 0xaaaa, 0xaaa8, 0x2a8a, 0xaa80, 
  107.     0xeaaa, 0xaaaa, 0xaaa8, 0xaa8a, 0xaa80, 
  108.     0xeaff, 0xffff, 0xffe8, 0x0a8a, 0xaa80, 
  109.     0xeaaa, 0xaaaa, 0xaae8, 0xaa8b, 0xfe80, 
  110.     0xea00, 0x0000, 0x0068, 0x028b, 0xaa80, 
  111.     0xea00, 0x0000, 0x0068, 0xaaab, 0xea80, 
  112.     0xea00, 0x0000, 0x0068, 0x00ab, 0xaa80, 
  113.     0xea55, 0x4000, 0x0068, 0x8aab, 0xaa80, 
  114.     0xea40, 0x0000, 0x4068, 0x002b, 0xfe80, 
  115.     0xea40, 0x0000, 0x4068, 0x8aaa, 0xaa80, 
  116.     0xea40, 0x0000, 0x4068, 0x080a, 0xaa80, 
  117.     0xea40, 0x0000, 0x0068, 0x8aaa, 0xaa80, 
  118.     0xea40, 0x0000, 0x0068, 0x0a02, 0xaa80, 
  119.     0xea00, 0x0154, 0x0068, 0x8aaa, 0xaa80, 
  120.     0xea00, 0x0000, 0x0068, 0x0a80, 0xaa80, 
  121.     0xea00, 0x0000, 0x0068, 0x8aaa, 0xaa80, 
  122.     0xea00, 0x0000, 0x0068, 0x0000, 0x2a80, 
  123.     0xe800, 0x0000, 0x0028, 0xaaaa, 0xaa80, 
  124.     0xeaaa, 0xaaaa, 0xaaa8, 0x0000, 0x0a80, 
  125.     0xeaaa, 0xaaaa, 0xaaa8, 0x0000, 0x0a80, 
  126.     0xeaaa, 0xaaaa, 0xaaaa, 0xaaaa, 0xaa80, 
  127.     0x8000, 0x0000, 0x0000, 0x0000, 0x0000, 
  128. };
  129.  
  130. struct Image gr = {
  131.     0,      /* LeftEdge */
  132.     0,      /* TopEdge */
  133.     76,     /* Width */
  134.     25,     /* Height */
  135.     2,      /* Depth */
  136.     gr_data,        /* ImageData */
  137.     3,      /* PlanePick */
  138.     0,      /* PlaneOnOff */
  139.     NULL,   /* NextImage */
  140. };
  141.  
  142. UWORD sr_data[] = {
  143.  
  144.     /* plane 0 */
  145.  
  146.     0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 
  147.     0x0000, 0x0000, 0x0000, 0x0000, 0x0030, 
  148.     0x0000, 0x0000, 0x0003, 0x0030, 0x0030, 
  149.     0x0000, 0x0000, 0x0002, 0x8030, 0x0030, 
  150.     0x0000, 0x0000, 0x0003, 0x4030, 0x0030, 
  151.     0x03ff, 0xffff, 0xffe2, 0xa030, 0x0030, 
  152.     0x03aa, 0xaaaa, 0xaae3, 0x5031, 0xfc30, 
  153.     0x0200, 0x0000, 0x0062, 0xa831, 0x8030, 
  154.     0x0200, 0x0000, 0x0063, 0x5401, 0xe030, 
  155.     0x0200, 0x0000, 0x0062, 0xaa01, 0x8030, 
  156.     0x0200, 0x0155, 0x4063, 0x7501, 0x8030, 
  157.     0x0200, 0x2100, 0x0062, 0xaa81, 0xfc30, 
  158.     0x0200, 0x2100, 0x0063, 0x6540, 0x0030, 
  159.     0x0200, 0x2100, 0x0062, 0xa2a0, 0x0030, 
  160.     0x0200, 0x2100, 0x4063, 0x6150, 0x0030, 
  161.     0x0200, 0x2100, 0x4062, 0xa0a8, 0x0030, 
  162.     0x0255, 0x6001, 0xf063, 0x6054, 0x0030, 
  163.     0x0200, 0x0000, 0x4062, 0xa02a, 0x0030, 
  164.     0x0200, 0x0000, 0x4063, 0x6015, 0x0030, 
  165.     0x0200, 0x0000, 0x0062, 0xbffa, 0x8030, 
  166.     0x02aa, 0xaaaa, 0xaaa3, 0x5555, 0x4030, 
  167.     0x0000, 0x0000, 0x0002, 0xaaaa, 0xa030, 
  168.     0x0000, 0x0000, 0x0003, 0xffff, 0xf030, 
  169.     0x0000, 0x0000, 0x0000, 0x0000, 0x0030, 
  170.     0x7fff, 0xffff, 0xffff, 0xffff, 0xfff0, 
  171.  
  172.     /* plane 1 */
  173.  
  174.     0xffff, 0xffff, 0xffff, 0xffff, 0xffe0, 
  175.     0xeaaa, 0xaaaa, 0xaaaa, 0xaaaa, 0xaa80, 
  176.     0xeaaa, 0xaaaa, 0xaaa8, 0xaaba, 0xaa80, 
  177.     0xeaaa, 0xaaaa, 0xaaa8, 0x2aba, 0xaa80, 
  178.     0xeaaa, 0xaaaa, 0xaaa8, 0xaaba, 0xaa80, 
  179.     0xeaff, 0xffff, 0xffe8, 0x0aba, 0xaa80, 
  180.     0xeaaa, 0xaaaa, 0xaae8, 0xaaba, 0x0280, 
  181.     0xea00, 0x0000, 0x0068, 0x02ba, 0x2a80, 
  182.     0xea00, 0x0000, 0x0068, 0xaaaa, 0x0a80, 
  183.     0xea00, 0x0000, 0x0068, 0x00aa, 0x2a80, 
  184.     0xea55, 0x4000, 0x0068, 0x8aaa, 0x2a80, 
  185.     0xea40, 0x0000, 0x4068, 0x002a, 0x0280, 
  186.     0xea40, 0x0000, 0x4068, 0x8aaa, 0xaa80, 
  187.     0xea40, 0x0000, 0x4068, 0x080a, 0xaa80, 
  188.     0xea40, 0x0000, 0x0068, 0x8aaa, 0xaa80, 
  189.     0xea40, 0x0000, 0x0068, 0x0a02, 0xaa80, 
  190.     0xea00, 0x0154, 0x0068, 0x8aaa, 0xaa80, 
  191.     0xea00, 0x0000, 0x0068, 0x0a80, 0xaa80, 
  192.     0xea00, 0x0000, 0x0068, 0x8aaa, 0xaa80, 
  193.     0xea00, 0x0000, 0x0068, 0x0000, 0x2a80, 
  194.     0xe800, 0x0000, 0x0028, 0xaaaa, 0xaa80, 
  195.     0xeaaa, 0xaaaa, 0xaaa8, 0x0000, 0x0a80, 
  196.     0xeaaa, 0xaaaa, 0xaaa8, 0x0000, 0x0a80, 
  197.     0xeaaa, 0xaaaa, 0xaaaa, 0xaaaa, 0xaa80, 
  198.     0x8000, 0x0000, 0x0000, 0x0000, 0x0000, 
  199. };
  200.  
  201. struct Image sr = {
  202.     0,      /* LeftEdge */
  203.     0,      /* TopEdge */
  204.     76,     /* Width */
  205.     25,     /* Height */
  206.     2,      /* Depth */
  207.     sr_data,        /* ImageData */
  208.     3,      /* PlanePick */
  209.     0,      /* PlaneOnOff */
  210.     NULL,   /* NextImage */
  211. };
  212.  
  213. char *tt[] = {
  214.     "»»» InterfaceEditor - ©1994-96 Simone Tellini «««",
  215.     NULL
  216. };
  217.  
  218. struct DiskObject IconStruct = {
  219.     WB_DISKMAGIC,   /* do_Magic */
  220.     WB_DISKVERSION, /* do_Version */
  221.     NULL,   /* do_Gadget.NextGadget */
  222.     0,     /* do_Gadget.LeftEdge */
  223.     0,     /* do_Gadget.TopEdge */
  224.     76,     /* do_Gadget.Width */
  225.     26,     /* do_Gadget.Height */
  226.     6, 1, 1,
  227.     (APTR)&gr,      /* do_Gadget.GadgetRender */
  228.     (APTR)&sr,      /* do_Gadget.SelectRender */
  229.     NULL,   /* do_Gadget.GadgetText */
  230.     0,      /* do_Gadget.MutualExclude */
  231.     NULL,   /* do_Gadget.SpecialInfo */
  232.     0,      /* do_Gadget.GadgetID */
  233.     (APTR)WB_DISKREVISION,  /* do_Gadget.UserData */
  234.     WBPROJECT,      /* do_Type */
  235.     &DefaultTool[0],   /* do_DefaultTool */
  236.     &tt[0], /* do_ToolTypes */
  237.     NO_ICON_POSITION,       /* do_CurrentX */
  238.     NO_ICON_POSITION,       /* do_CurrentY */
  239.     NULL,   /* do_DrawerData */
  240.     NULL,   /* do_ToolWindow */
  241.     8192,   /* do_StackSize */
  242. };
  243. ///
  244.  
  245.  
  246. /// Put string 2
  247. void PutString2( STRPTR str )
  248. {
  249.     UWORD   len;
  250.  
  251.     len = strlen( str );
  252.  
  253.     FWrite( File, &len, 2, 1 );
  254.     FWrite( File, str, len, 1 );
  255.  
  256.     if( len & 1 )
  257.     FPutC( File, 0 );
  258. }
  259. ///
  260. /// Get e Put string
  261. void FGetString( UBYTE *str )
  262. {
  263.     UBYTE   len;
  264.  
  265.     len = FGetC( File );
  266.  
  267.     FRead( File, str, len, 1 );
  268.  
  269.     str[ len ] = '\0';
  270.  
  271.     if(!( len & 1 ))
  272.     FGetC( File );
  273. }
  274.  
  275. void PutString( STRPTR str )
  276. {
  277.     UBYTE   len;
  278.  
  279.     len = strlen( str );
  280.  
  281.     FPutC( File, len );
  282.     FWrite( File, str, len, 1 );
  283.  
  284.     if(!( len & 1 ))
  285.     FPutC( File, 0 );
  286. }
  287. ///
  288. /// CountNodes
  289. ULONG CountNodes( struct MinList *List )
  290. {
  291.     ULONG           cnt = 0;
  292.     struct Node    *node;
  293.  
  294.     for( node = List->mlh_Head; node->ln_Succ; node = node->ln_Succ )
  295.     ++cnt;
  296.  
  297.     return( cnt );
  298. }
  299. ///
  300. /// AskFile
  301. BOOL AskFile( STRPTR File )
  302. {
  303.     BOOL    ret = TRUE;
  304.     BPTR    lock;
  305.  
  306.     if( lock = Lock( File, ACCESS_READ )) {
  307.     ULONG   tags[] = { RT_ReqPos,       REQPOS_CENTERSCR,
  308.                RT_Underscore,   '_',
  309.                RT_Screen,       Scr,
  310.                TAG_DONE };
  311.  
  312.     UnLock( lock );
  313.  
  314.     ret = rtEZRequest( "%s alreay exists.\n"
  315.                "Overwrite?",
  316.                CatCompArray[ ANS_YES_NO ].cca_Str,
  317.                NULL, (struct TagItem *)tags,
  318.                FilePart( File )
  319.              );
  320.     }
  321.  
  322.     return( ret );
  323. }
  324. ///
  325.  
  326.  
  327. /// Locale
  328. void WriteLocale( void )
  329. {
  330.     PutString( IE.Locale->Catalog );
  331.     PutString( IE.Locale->JoinFile );
  332.     PutString( IE.Locale->BuiltIn );
  333.  
  334.     FWrite( File, &IE.Locale->Version, 4, 1 );
  335. }
  336. ///
  337. /// LocaleStuff
  338. void WriteLocaleStuff( void )
  339. {
  340.     ULONG                       num;
  341.     struct LocaleLanguage      *lang;
  342.     struct LocaleStr           *str;
  343.  
  344.     num = CountNodes( &IE.Locale->Languages );
  345.  
  346.     FWrite( File, &num, 4, 1 );
  347.  
  348.     for( lang = IE.Locale->Languages.mlh_Head; lang->Node.ln_Succ; lang = lang->Node.ln_Succ ) {
  349.     PutString( lang->Language );
  350.     PutString( lang->File );
  351.     }
  352.  
  353.     num = CountNodes( &IE.Locale->ExtraStrings );
  354.  
  355.     FWrite( File, &num, 4, 1 );
  356.  
  357.     for( str = IE.Locale->ExtraStrings.mlh_Head; str->Node.ln_Succ; str = str->Node.ln_Succ ) {
  358.     struct LocaleTranslation   *tran;
  359.     UWORD                       flags;
  360.  
  361.     flags = str->Node.ln_Pri;
  362.  
  363.     FWrite( File, &flags, 2, 1 );
  364.  
  365.     PutString2( str->Node.ln_Name );
  366.     PutString( str->ID );
  367.  
  368.     num = CountNodes( &str->Translations );
  369.  
  370.     FWrite( File, &num, 4, 1 );
  371.  
  372.     for( tran = str->Translations.mlh_Head; tran->Node.ln_Succ; tran = tran->Node.ln_Succ ) {
  373.  
  374.         PutString2( tran->String );
  375.  
  376.         FPutC( File, tran->Node.ln_Type );
  377.         FPutC( File, 0 );
  378.     }
  379.     }
  380. }
  381. ///
  382.  
  383. /// Main Proc
  384. void WriteMainProc( void )
  385. {
  386.     UWORD   data;
  387.     APTR    node;
  388.  
  389.     PutString( IE.ExtraProc );
  390.  
  391.     data = IE.MainProcFlags;
  392.  
  393.     FWrite( File, &data, 2, 1 );
  394.  
  395.     FWrite( File, &IE.NumLibs, 2 , 1 );
  396.  
  397. #define no ((struct LibNode *)node)
  398.  
  399.     for( no = IE.Libs_List.mlh_Head; no->lbn_Node.ln_Succ; no = no->lbn_Node.ln_Succ ){
  400.  
  401.     PutString( no->lbn_Name );
  402.     PutString( no->lbn_Base );
  403.     FWrite( File, &no->lbn_Version, 2, 1 );
  404.     FWrite( File, &no->lbn_Node.ln_Type, 2, 1 );
  405.     }
  406.  
  407. #undef  no
  408.  
  409.     FWrite( File, &IE.NumWndTO, 2 , 1 );
  410.  
  411. #define no ((struct WndToOpen *)node)
  412.  
  413.     for( no  = IE.WndTO_List.mlh_Head; no->wto_Node.ln_Succ; no = no->wto_Node.ln_Succ )
  414.     PutString( no->wto_Label );
  415.  
  416. #undef no
  417. }
  418. ///
  419.  
  420. /// ARexx
  421. void WriteARexx( void )
  422. {
  423.     struct RexxNode *node;
  424.  
  425.     PutString( IE.RexxPortName );
  426.     PutString( IE.RexxExt );
  427.  
  428.     FWrite( File, &IE.NumRexxs, 2, 1 );
  429.  
  430.     for( node = IE.Rexx_List.mlh_Head; node->rxn_Node.ln_Succ; node = node->rxn_Node.ln_Succ ) {
  431.  
  432.     PutString( node->rxn_Label );
  433.     PutString( node->rxn_Name );
  434.     PutString( node->rxn_Template );
  435.  
  436.     }
  437. }
  438. ///
  439.  
  440. /// Menus
  441. void WriteMenus( struct WindowInfo *wnd )
  442. {
  443.     struct MenuTitle   *title;
  444.     struct _MenuItem   *item;
  445.     struct MenuSub     *sub;
  446.     WORD                num;
  447.  
  448.     for( title = wnd->wi_Menus.mlh_Head; title->mt_Node.ln_Succ; title = title->mt_Node.ln_Succ ) {
  449.  
  450.     FWrite( File, &title->mt_Flags, 4, 1 );  // Flags, Pad, NumItems
  451.  
  452.     PutString( title->mt_Text );
  453.     PutString( title->mt_Label );
  454.  
  455.     for( item = title->mt_Items.mlh_Head; item->min_Node.ln_Succ; item = item->min_Node.ln_Succ ) {
  456.  
  457.         FWrite( File, &item->min_Flags, 2, 1 );
  458.  
  459.         PutString( item->min_Text );
  460.         PutString( item->min_CommKey );
  461.         PutString( item->min_Label );
  462.  
  463.         if( item->min_Image ) {
  464.         num = GetNodeNum( &IE.Img_List, (APTR)((ULONG)item->min_Image - 14 ));
  465.         } else {
  466.         num = -1;
  467.         }
  468.  
  469.         FWrite( File, &num, 2, 1 );
  470.         FWrite( File, &item->min_MutualExclude, 6, 1 ); // Mutual Exclude, NumSubs
  471.  
  472.         for( sub = item->min_Subs.mlh_Head; sub->msn_Node.ln_Succ; sub = sub->msn_Node.ln_Succ) {
  473.  
  474.         FWrite( File, &sub->msn_Flags, 2, 1 );
  475.  
  476.         PutString( sub->msn_Text );
  477.         PutString( sub->msn_CommKey );
  478.         PutString( sub->msn_Label );
  479.  
  480.         if( sub->msn_Image ) {
  481.             num = GetNodeNum( &IE.Img_List, (APTR)((ULONG)sub->msn_Image - 14 ));
  482.         } else {
  483.             num = -1;
  484.         }
  485.  
  486.         FWrite( File, &num, 2, 1 );
  487.         FWrite( File, &sub->msn_MutualExclude, 4, 1 );
  488.  
  489.         }
  490.     }
  491.     }
  492. }
  493. ///
  494.  
  495. /// SistemaImg
  496. void SistemaImg( void )
  497. {
  498.     struct WindowInfo  *wnd;
  499.     struct WndImages   *wimg;
  500.     struct ImageNode   *img;
  501.     UWORD               cnt;
  502.     WORD                num;
  503.     APTR                ptr;
  504.  
  505.     for( wnd = IE.win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  506.  
  507.     for( wimg = wnd->wi_Images.mlh_Head; wimg->wim_Next; wimg = wimg->wim_Next ) {
  508.  
  509.         img = (struct ImageNode *)&IE.Img_List;
  510.         for( cnt = 0; cnt <= (LONG)wimg->wim_ImageNode; cnt++ )
  511.         img = img->in_Node.ln_Succ;
  512.  
  513.         wimg->wim_ImageNode = img;
  514.         memcpy( &img->in_Width, &wimg->wim_Width, 12 );
  515.  
  516.     }
  517.  
  518.     ptr = NULL;  // sistemo i ptr NextImage
  519.     for( wimg = wnd->wi_Images.mlh_TailPred; wimg->wim_Prev; wimg = wimg->wim_Prev ) {
  520.         wimg->wim_NextImage = ptr;
  521.         ptr = &wimg->wim_Left;
  522.     }
  523.  
  524.     // sistemo i booleani
  525.     struct BooleanInfo *bool;
  526.     for( bool = wnd->wi_Gadgets.mlh_Head; bool->b_Node.ln_Succ; bool = bool->b_Node.ln_Succ ) {
  527.         if( bool->b_Kind == BOOLEAN ) {
  528.  
  529.         num = (LONG)bool->b_GadgetRender;
  530.  
  531.         if( num >= 0 ) {
  532.  
  533.             img = (struct ImageNode *)&IE.Img_List;
  534.             for( cnt = 0; cnt <= num; cnt++ )
  535.             img = img->in_Node.ln_Succ;
  536.             bool->b_GadgetRender = &img->in_Left;
  537.  
  538.         } else {
  539.             bool->b_GadgetRender = NULL;
  540.         }
  541.  
  542.         num = (LONG)bool->b_SelectRender;
  543.  
  544.         if( num >= 0 ) {
  545.  
  546.             img = (struct ImageNode *)&IE.Img_List;
  547.             for( cnt = 0; cnt <= num; cnt++ )
  548.             img = img->in_Node.ln_Succ;
  549.             bool->b_SelectRender = &img->in_Left;
  550.  
  551.         } else {
  552.             bool->b_SelectRender = NULL;
  553.         }
  554.  
  555.         }
  556.     }
  557.  
  558.     // sistemo i menu
  559.  
  560.     struct MenuTitle *title;
  561.     struct _MenuItem *item;
  562.     struct MenuSub   *sub;
  563.     for( title = wnd->wi_Menus.mlh_Head; title->mt_Node.ln_Succ; title = title->mt_Node.ln_Succ ) {
  564.         for( item = title->mt_Items.mlh_Head; item->min_Node.ln_Succ; item = item->min_Node.ln_Succ ) {
  565.  
  566.         num = (LONG)item->min_Image;
  567.  
  568.         if( num >= 0 ) {
  569.             img = (struct ImageNode *)&IE.Img_List;
  570.             for( cnt = 0; cnt <= num; cnt++ )
  571.             img = img->in_Node.ln_Succ;
  572.             item->min_Image = &img->in_Left;
  573.         } else {
  574.             item->min_Image = NULL;
  575.         }
  576.  
  577.         for( sub = item->min_Subs.mlh_Head; sub->msn_Node.ln_Succ; sub = sub->msn_Node.ln_Succ ) {
  578.  
  579.             num = (LONG)sub->msn_Image;
  580.  
  581.             if( num >= 0 ) {
  582.             img = (struct ImageNode *)&IE.Img_List;
  583.             for( cnt = 0; cnt <= num; cnt++ )
  584.                 img = img->in_Node.ln_Succ;
  585.             sub->msn_Image = &img->in_Left;
  586.             } else {
  587.             sub->msn_Image = NULL;
  588.             }
  589.         }
  590.  
  591.         }
  592.     }
  593.     }
  594. }
  595. ///
  596.  
  597. /// Immagini
  598. void WriteImg( void )
  599. {
  600.     struct ImageNode    *img;
  601.  
  602.     FWrite( File, &IE.NumImgs, 2, 1 );
  603.  
  604.     for( img = IE.Img_List.mlh_Head; img->in_Node.ln_Succ; img = img->in_Node.ln_Succ ){
  605.  
  606.     FWrite( File, &img->in_Width, 6, 1 ); // Width, Height, Depth
  607.     FWrite( File, &img->in_Size, 4, 1 );
  608.     FWrite( File, img->in_Data, img->in_Size, 1 );
  609.     FWrite( File, &img->in_PlanePick, 2, 1 );
  610.  
  611.     PutString( img->in_Label );
  612.  
  613.     }
  614. }
  615. ///
  616.  
  617. /// IntuiTexts
  618. void WriteITexts( struct WindowInfo *wnd )
  619. {
  620.     struct ITextNode   *itn;
  621.     WORD                more;
  622.  
  623.     FWrite( File, &wnd->wi_NumTexts, 2, 1 );
  624.  
  625.     for( itn = wnd->wi_ITexts.mlh_Head; itn->itn_Node.ln_Succ; itn = itn->itn_Node.ln_Succ ) {
  626.  
  627.     itn->itn_AdjustToWord = itn->itn_Node.ln_Type;
  628.     FWrite( File, &itn->itn_FrontPen, 8, 1 );
  629.     itn->itn_AdjustToWord = 0;
  630.  
  631.     PutString( itn->itn_Text );
  632.  
  633.     if( itn->itn_FontCopy )
  634.         more = TRUE;
  635.     else
  636.         more = FALSE;
  637.  
  638.     FWrite( File, &more, 2, 1 );
  639.  
  640.     if( more ){
  641.  
  642.         PutString( itn->itn_FontCopy->ta_Name );
  643.         FWrite( File, &itn->itn_FontCopy->ta_YSize, 4, 1 );
  644.  
  645.     }
  646.     }
  647. }
  648. ///
  649.  
  650. /// Immagini (nelle finestre)
  651. void WriteImages( struct WindowInfo *wnd )
  652. {
  653.     struct WndImages   *img;
  654.     UWORD               num;
  655.  
  656.     FWrite( File, &wnd->wi_NumImages, 2, 1 );
  657.  
  658.     for( img = wnd->wi_Images.mlh_Head; img->wim_Next; img = img->wim_Next ) {
  659.  
  660.     FWrite( File, &img->wim_Left, 4, 1 );
  661.     num = GetNodeNum( &IE.Img_List, img->wim_ImageNode );
  662.     FWrite( File, &num, 2, 1 );
  663.  
  664.     }
  665. }
  666. ///
  667.  
  668. /// Bevel Box
  669. void WriteBoxes( struct WindowInfo *wnd )
  670. {
  671.     struct BevelBoxNode *box;
  672.  
  673.     for( box = wnd->wi_Boxes.mlh_Head; box->bb_Next; box = box->bb_Next ) {
  674.  
  675.     FWrite( File, &box->bb_Left, 8, 1 );
  676.     FWrite( File, &box->bb_Recessed, 4, 1 );
  677.     FWrite( File, &box->bb_FrameType, 4, 1 );
  678.  
  679.     }
  680. }
  681. ///
  682.  
  683. /// Finestre
  684. void WriteWin( struct WindowInfo *wnd )
  685. {
  686.     FWrite( File, &wnd->wi_Top, 44, 1 );
  687.     PutString( wnd->wi_Titolo );
  688.     PutString( wnd->wi_TitoloSchermo );
  689.     PutString( wnd->wi_Label );
  690. }
  691. ///
  692.  
  693. /// Gadgets
  694. void WriteGad( struct GadgetInfo *gad )
  695. {
  696.     struct GadgetScelta *gs;
  697.     ULONG                data = 0;
  698.  
  699.     FWrite( File, &gad->g_Left, 8, 1 ); // g_Left-g_Height
  700.     FWrite( File, &gad->g_Flags, 4, 1 );
  701.     FWrite( File, &gad->g_Kind, 2, 1 );
  702.     FWrite( File, &gad->g_Tags, 32, 1 );
  703.  
  704.     if( gad->g_flags2 & G_NO_TEMPLATE )
  705.     data = 1;
  706.  
  707.     FWrite( File, &data, 4, 1 );
  708.  
  709.     if( gad->g_Font )
  710.     FWrite( File, &gad->g_Font->txa_Size, 4, 1 );
  711.     else
  712.     FWrite( File, &data, 4, 1 );
  713.  
  714.     FWrite( File, &gad->g_NumScelte, 2, 1 );
  715.  
  716.     for( gs = gad->g_Scelte.mlh_Head; gs->gs_Node.ln_Succ; gs = gs->gs_Node.ln_Succ )
  717.     PutString( gs->gs_Testo );
  718.  
  719.     if(( gad->g_Kind == STRING_KIND ) || ( gad->g_Kind == TEXT_KIND ))
  720.     PutString( gad->g_ExtraMem );
  721.  
  722.     PutString( gad->g_Titolo );
  723.     PutString( gad->g_Label );
  724.  
  725.     if( gad->g_Font )
  726.     PutString( gad->g_Font->txa_FontName );
  727.     else
  728.     FWrite( File, &data, 2, 1 );
  729. }
  730. ///
  731.  
  732. /// Booleani
  733. void WriteBool( struct BooleanInfo *gad )
  734. {
  735.     WORD        num;
  736.     ULONG       data = 0;
  737.  
  738.     FWrite( File, &gad->b_Left, 14, 1 );
  739.  
  740.     if( gad->b_GadgetRender )
  741.     num = GetNodeNum( &IE.Img_List, (APTR)((ULONG)gad->b_GadgetRender - 14 ));
  742.     else
  743.     num = -1;
  744.  
  745.     FWrite( File, &num, 2, 1 );
  746.  
  747.     if( gad->b_SelectRender )
  748.     num = GetNodeNum( &IE.Img_List, (APTR)((ULONG)gad->b_SelectRender - 14 ));
  749.     else
  750.     num = -1;
  751.  
  752.     FWrite( File, &num, 2, 1 );
  753.  
  754.     FWrite( File, &gad->b_FrontPen, 8, 1 );
  755.  
  756.     if( gad->b_flags2 & G_NO_TEMPLATE )
  757.     data = 1;
  758.  
  759.     FWrite( File, &data, 4, 1 );
  760.  
  761.     if( gad->b_Font )
  762.     FWrite( File, &gad->b_Font->txa_Size, 4, 1 );
  763.     else
  764.     FWrite( File, &data, 4, 1 );
  765.  
  766.     num = ( gad->b_flags2 & B_TEXT ) ? -1 : 0;
  767.     FPutC( File, num );
  768.  
  769.     num = strlen( gad->b_Titolo );
  770.     FPutC( File, num );
  771.     FWrite( File, gad->b_Titolo, num, 1 );
  772.     if( num & 1 )
  773.     FPutC( File, 0 );
  774.  
  775.     PutString( gad->b_Label );
  776.  
  777.     FWrite( File, &data, 2, 1 );
  778.  
  779.     if( gad->b_Font )
  780.     PutString( gad->b_Font->txa_FontName );
  781.     else
  782.     FWrite( File, &data, 2, 1 );
  783. }
  784. ///
  785.  
  786.  
  787. //      Salvataggio
  788. /// Salva GUI
  789. BOOL SalvaComeMenued( void )
  790. {
  791.     UBYTE   *ptr;
  792.  
  793.     if(!( GetFile2( TRUE, CatCompArray[ ASL_SAVE_GUI ].cca_Str, RawDataPattern,
  794.            ASL_SAVE_GUI, GUI_ext ))) {
  795.     return( TRUE );
  796.     }
  797.  
  798.     ptr = allpath;
  799.  
  800.     while( *ptr != '\0' )
  801.     if( *ptr++ == '.' )
  802.         break;
  803.  
  804.     if( *ptr == '\0' )
  805.     strcat( allpath, ".gui" );
  806.  
  807.     strcpy( save_file, allpath );
  808.  
  809.     return( SalvaMenued() );
  810. }
  811.  
  812. BOOL SalvaMenued( void )
  813. {
  814.     struct WindowInfo  *wnd, *backwnd;
  815.     struct GadgetInfo  *gad;
  816.     UWORD               data2;
  817.  
  818.     if( IE.flags_2 & DEMO )
  819.     return( TRUE );
  820.  
  821.     if(!( save_file[0] )) {
  822.     SalvaComeMenued();
  823.     return( TRUE );
  824.     }
  825.  
  826.     Stat( CatCompArray[ MSG_SAVING ].cca_Str, FALSE, 0 );
  827.  
  828.     if(!( GetStrings() )) {
  829.     Stat( CatCompArray[ ERR_NOMEMORY ].cca_Str, TRUE, 0 );
  830.     return( TRUE );
  831.     }
  832.  
  833.     if(!( File = Open( save_file, MODE_NEWFILE ))) {
  834.     Stat( CatCompArray[ ERR_IOERR ].cca_Str, TRUE, 0 );
  835.     return( TRUE );
  836.     }
  837.  
  838.     backwnd = IE.win_info;
  839.  
  840.  
  841.     FWrite( File, DataHeader, 8, 1 );
  842.     FWrite( File, &InterfHeader, 4, 1 );
  843.  
  844.     FPutC( File, IE.SrcFlags );
  845.  
  846.     if( IE.flags_2 & GENERASCR )
  847.     FPutC( File, -1 );
  848.     else
  849.     FPutC( File, 0 );
  850.  
  851.     WriteScr();
  852.  
  853.     DetacheGBanks();
  854.     GadgetsDown();
  855.  
  856.     FWrite( File, &IE.num_win, 2, 1 );
  857.  
  858.     for( wnd = IE.win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  859.  
  860.     WriteWin( wnd );
  861.  
  862.     data2 = wnd->wi_NumGads - wnd->wi_NumBools;
  863.  
  864.     FWrite( File, &data2, 2, 1 );
  865.  
  866.     for( gad = wnd->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  867.         if( gad->g_Kind < BOOLEAN )
  868.         WriteGad( gad );
  869.     }
  870.  
  871.     FWrite( File, &wnd->wi_NumMenus, 2, 1 );
  872.     if( wnd->wi_NumMenus )
  873.         WriteMenus( wnd );
  874.  
  875.     FWrite( File, &wnd->wi_NumBools, 2, 1 );
  876.     for( gad = wnd->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  877.         if( gad->g_Kind == BOOLEAN )
  878.         WriteBool(( struct BooleanInfo *)gad );
  879.     }
  880.  
  881.     FWrite( File, &wnd->wi_NumBoxes, 2, 1 );
  882.     WriteBoxes( wnd );
  883.  
  884.     WriteImages( wnd );
  885.  
  886.     data2 = -1;
  887.     FWrite( File, &data2, 2, 1 );
  888.  
  889.     WriteITexts( wnd );
  890.  
  891.     FWrite( File, &data2, 2, 1 );
  892.     FWrite( File, &wnd->wi_NumObjects, 2, 1 );
  893.  
  894.     if( wnd->wi_NumObjects ) {
  895.  
  896.         struct IEXNode *ex;
  897.  
  898.         for( ex = IE.Expanders.mlh_Head; ex->Node.ln_Succ; ex = ex->Node.ln_Succ ) {
  899.         UWORD   num = 0;
  900.  
  901.         for( gad = wnd->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ )
  902.             if( gad->g_Kind == ex->ID ) {
  903.             if( gad->g_flags2 & G_ATTIVO )
  904.                 gad->g_flags2 |= G_WAS_ACTIVE;
  905.             else
  906.                 gad->g_flags2 |= G_ATTIVO;
  907.             num += 1;
  908.             }
  909.  
  910.         if( num ) {
  911.             FWrite( File, &num, 2, 1 );
  912.             PutString( ex->Base->Lib.lib_Node.ln_Name );
  913.  
  914.             IEXBase = ex->Base;
  915.  
  916.             IE.win_info = wnd;
  917.             IEX_Save( ex->ID, &IE, File );
  918.  
  919.             FWrite( File, "IEXN", 4, 1 );   /* Next IEX */
  920.  
  921.             for( gad = wnd->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ )
  922.             if( gad->g_Kind == ex->ID )
  923.                 if( gad->g_flags2 & G_WAS_ACTIVE )
  924.                 gad->g_flags2 &= ~G_WAS_ACTIVE;
  925.                 else
  926.                 gad->g_flags2 &= ~G_ATTIVO;
  927.         }
  928.         }
  929.     }
  930.  
  931.     FWrite( File, &data2, 2, 1 );
  932.  
  933.     FWrite( File, &wnd->wi_NumGBanks, 2, 1 );
  934.  
  935.     {
  936.         struct GadgetBank  *bank;
  937.  
  938.         for( bank = wnd->wi_GBanks.mlh_Head; bank->Node.ln_Succ; bank = bank->Node.ln_Succ ) {
  939.         UWORD   gadtools = 0, bools = 0, ext = 0;
  940.  
  941.         PutString( bank->Label );
  942.  
  943.         for( gad = bank->Storage.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  944.  
  945.             if( gad->g_Kind < BOOLEAN )
  946.             gadtools += 1;
  947.             else {
  948.             if( gad->g_Kind == BOOLEAN )
  949.                 bools += 1;
  950.             else
  951.                 ext += 1;
  952.             }
  953.         }
  954.  
  955.         FWrite( File, &gadtools, 2, 1 );
  956.         for( gad = bank->Storage.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ )
  957.             if( gad->g_Kind < BOOLEAN )
  958.             WriteGad( gad );
  959.  
  960.         FWrite( File, &bools, 2, 1 );
  961.         for( gad = bank->Storage.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ )
  962.             if( gad->g_Kind == BOOLEAN )
  963.             WriteBool(( struct BooleanInfo * )gad );
  964.  
  965.         FWrite( File, &ext, 2, 1 );
  966.         }
  967.     }
  968.  
  969.  
  970.     data2 = 0;
  971.     FWrite( File, &data2, 2, 1 );
  972.     }
  973.  
  974.     WriteImg();
  975.  
  976.     data2 = 0;
  977.  
  978.     FWrite( File, &data2, 2, 1 );
  979.     WriteARexx();
  980.  
  981.     FWrite( File, &data2, 2, 1 );
  982.     WriteMainProc();
  983.  
  984.     FWrite( File, &data2, 2, 1 );
  985.     WriteLocale();
  986.  
  987.     PutString( IE.SharedPort );
  988.  
  989.     WriteLocaleStuff();
  990.  
  991.     Close( File );
  992.  
  993.     if( IE.mainprefs & CREAICONE )
  994.     PutDiskObject( allpath, &IconStruct );
  995.  
  996.     IE.flags |= SALVATO;
  997.  
  998.     GadgetsUp();
  999.     ReAttachGBanks();
  1000.     PutStrings();
  1001.  
  1002.     Stat( CatCompArray[ MSG_SAVED ].cca_Str, FALSE, 0 );
  1003.  
  1004.     IE.win_info = backwnd;
  1005.  
  1006.     return( TRUE );
  1007. }
  1008. ///
  1009. /// Salva Finestra
  1010. BOOL SalvaWndMenued( void )
  1011. {
  1012.     if(!( GetFile2( TRUE, CatCompArray[ ASL_SAVE_WND ].cca_Str, FinestraPattern,
  1013.            ASL_SAVE_WND, WND_ext )))
  1014.     return( TRUE );
  1015.  
  1016.     if(!( File = Open( allpath, MODE_NEWFILE ))) {
  1017.     Stat( CatCompArray[ ERR_IOERR ].cca_Str, TRUE, 0 );
  1018.     return( TRUE );
  1019.     }
  1020.  
  1021.     Stat( CatCompArray[ MSG_SAVING ].cca_Str, FALSE, 0 );
  1022.  
  1023.     FWrite( File, DataHeader, 8, 1 );
  1024.     FWrite( File, &FinestraHeader, 4, 1 );
  1025.  
  1026.     WriteWin( IE.win_info );
  1027.  
  1028.     Close( File );
  1029.  
  1030.     Stat( CatCompArray[ MSG_SAVED ].cca_Str, FALSE, 0 );
  1031. }
  1032. ///
  1033. /// Salva Gadgets
  1034. BOOL SalvaGadMenued( void )
  1035. {
  1036.     struct GadgetInfo  *gad;
  1037.     UWORD               num;
  1038.  
  1039.     if(!( TestAttivi() ))
  1040.     return( TRUE );
  1041.  
  1042.     if(!( GetFile2( TRUE, CatCompArray[ ASL_SAVE_GAD ].cca_Str, GadgetPattern,
  1043.            ASL_SAVE_GAD, GAD_ext )))
  1044.     return( TRUE );
  1045.  
  1046.     if(!( File = Open( allpath, MODE_NEWFILE ))) {
  1047.     Stat( CatCompArray[ ERR_IOERR ].cca_Str, TRUE, 0 );
  1048.     return( TRUE );
  1049.     }
  1050.  
  1051.     Stat( CatCompArray[ MSG_SAVING ].cca_Str, FALSE, 0 );
  1052.  
  1053.     FWrite( File, DataHeader, 8, 1 );
  1054.     FWrite( File, &GadgetHeader, 4, 1 );
  1055.  
  1056.     num = 0;
  1057.     for( gad = IE.win_info->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  1058.     if(( gad->g_flags2 & G_ATTIVO ) && ( gad->g_Kind < BOOLEAN ))
  1059.         num += 1;
  1060.     }
  1061.  
  1062.     FWrite( File, &num, 2, 1 );
  1063.  
  1064.     GadgetsDown();
  1065.  
  1066.     for( gad = IE.win_info->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  1067.     if(( gad->g_flags2 & G_ATTIVO ) && ( gad->g_Kind < BOOLEAN ))
  1068.         WriteGad( gad );
  1069.     }
  1070.  
  1071.     num = 0;
  1072.     for( gad = IE.win_info->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  1073.     if(( gad->g_flags2 & G_ATTIVO ) && ( gad->g_Kind == BOOLEAN ))
  1074.         num += 1;
  1075.     }
  1076.  
  1077.     FWrite( File, &num, 2, 1 );
  1078.  
  1079.     for( gad = IE.win_info->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  1080.     if(( gad->g_flags2 & G_ATTIVO ) && ( gad->g_Kind == BOOLEAN ))
  1081.         WriteBool(( struct BooleanInfo *)gad );
  1082.     }
  1083.  
  1084.     if( num ) {
  1085.     num = 0;
  1086.     FWrite( File, &num, 2, 1 );
  1087.     } else {
  1088.     WriteImg();
  1089.     }
  1090.  
  1091.     FWrite( File, &IE.win_info->wi_NumObjects, 2, 1 );
  1092.  
  1093.     if( IE.win_info->wi_NumObjects ) {
  1094.     struct IEXNode *ex;
  1095.  
  1096.     for( ex = IE.Expanders.mlh_Head; ex->Node.ln_Succ; ex = ex->Node.ln_Succ ) {
  1097.         UWORD   num = 0;
  1098.  
  1099.         for( gad = IE.win_info->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ )
  1100.         if( gad->g_Kind == ex->ID )
  1101.             num += 1;
  1102.  
  1103.         if( num ) {
  1104.         FWrite( File, &num, 2, 1 );
  1105.         PutString( ex->Base->Lib.lib_Node.ln_Name );
  1106.  
  1107.         IEXBase = ex->Base;
  1108.         IEX_Save( ex->ID, &IE, File );
  1109.  
  1110.         FWrite( File, "IEXN", 4, 1 );   /* Next IEX */
  1111.         }
  1112.     }
  1113.     }
  1114.  
  1115.     GadgetsUp();
  1116.  
  1117.     Close( File );
  1118.  
  1119.     Stat( CatCompArray[ MSG_GAD_SAVED ].cca_Str, FALSE, 0 );
  1120.  
  1121.     return( TRUE );
  1122. }
  1123. ///
  1124.  
  1125. //      Caricamento
  1126. /// Carica GUI
  1127. BOOL LoadGUIClicked( void )
  1128. {
  1129.     return( CaricaMenued() );
  1130. }
  1131.  
  1132. BOOL CaricaMenued( void )
  1133. {
  1134.     ULONG               ret, ret2 = 0L, cnt;
  1135.     struct LoaderNode  *loader;
  1136.  
  1137.     loader = Loaders.mlh_Head;
  1138.  
  1139.     if(!( loader->Node.ln_Succ ))
  1140.     return( TRUE );
  1141.  
  1142.     if(!( IE.flags & LOADGUI )) {
  1143.     if(!( GetFile2( FALSE, CatCompArray[ ASL_LOADGUI ].cca_Str, RawDataPattern,
  1144.             ASL_LOADGUI, GUI_ext )))
  1145.         return( TRUE );
  1146.     else {
  1147.         if( IE.num_win ) {
  1148.         EliminaAllWndMenued();
  1149.         if( IE.num_win ) {
  1150.             Stat( CatCompArray[ MSG_ABORTED ].cca_Str, FALSE, 0 );
  1151.             return( TRUE );
  1152.         }
  1153.         }
  1154.     }
  1155.     } else {
  1156.     IE.flags &= ~LOADGUI;
  1157.     }
  1158.  
  1159.     ClearGUI();
  1160.  
  1161.     Stat( CatCompArray[ MSG_LOADING ].cca_Str, FALSE, 0 );
  1162.  
  1163.     do {
  1164.  
  1165.     LoaderBase = loader->LoaderBase;
  1166.  
  1167.     if(!( ret = LoadGUI( &IE, allpath2 ))) {
  1168.         UpdateScr();
  1169.         IE.flags |= SALVATO;
  1170.     } else {
  1171.         if( ret != LOADER_UNKNOWN ) {
  1172.         switch( ret ) {
  1173.             case LOADER_IOERR:
  1174.             Stat( CatCompArray[ ERR_IOERR ].cca_Str, TRUE, 0 );
  1175.             break;
  1176.  
  1177.             case LOADER_UNWELCOME:
  1178.             Stat( CatCompArray[ ERR_NOT_PROJECT ].cca_Str, TRUE, 0 );
  1179.             break;
  1180.  
  1181.             case LOADER_WRONGVERSION:
  1182.             Stat( CatCompArray[ MSG_WRONG_VERSION ].cca_Str, TRUE, 0 );
  1183.             break;
  1184.  
  1185.             case LOADER_NOTSUPPORTED:
  1186.             ret2 = ret;
  1187.             break;
  1188.         }
  1189.         return( TRUE );
  1190.         }
  1191.     }
  1192.  
  1193.     loader = loader->Node.ln_Succ;
  1194.  
  1195.     } while(( ret == LOADER_UNKNOWN ) && ( loader->Node.ln_Succ ));
  1196.  
  1197.     if( ret != LOADER_OK ) {
  1198.     switch( ret2 ) {
  1199.         case LOADER_NOTSUPPORTED:
  1200.         Stat( CatCompArray[ ERR_NOT_SUPPORTED ].cca_Str, TRUE, 0 );
  1201.         break;
  1202.         default:
  1203.         Stat( CatCompArray[ ERR_DATA_FORMAT ].cca_Str, TRUE, 0 );
  1204.     }
  1205.     return( TRUE );
  1206.     }
  1207.  
  1208.     for( cnt = 0; cnt < ATTIVA_CARICATA_NUM; cnt++ )
  1209.     OnMenu( BackWnd, attivamenu_nuovawin[ cnt ] );
  1210.  
  1211.     strcpy( save_file, allpath2 );
  1212.  
  1213.     GadgetsUp();
  1214.  
  1215.     Stat( CatCompArray[ MSG_LOADED ].cca_Str, FALSE, 0 );
  1216.  
  1217.     if( IE.flags & NODISKFONT ) {
  1218.     IE.flags &= ~NODISKFONT;
  1219.     IERequest( CatCompArray[ MSG_NO_DISKFONT ].cca_Str, ok_txt, 0, 0 );
  1220.     }
  1221.  
  1222.     if( IE.flags & NO_IEX ) {
  1223.     IE.flags &= ~NO_IEX;
  1224.     IERequest( CatCompArray[ MSG_NO_IEX ].cca_Str, ok_txt, 0, 0 );
  1225.     }
  1226.  
  1227.     return( TRUE );
  1228. }
  1229. ///
  1230. /// Carica Finestra
  1231. BOOL CaricaWndMenued( void )
  1232. {
  1233.     UWORD               cnt;
  1234.     ULONG               ret, ret2 = 0L;
  1235.     struct LoaderNode  *loader;
  1236.  
  1237.     loader = Loaders.mlh_Head;
  1238.  
  1239.     if(!( loader->Node.ln_Succ ))
  1240.     return( TRUE );
  1241.  
  1242.     if(!( GetFile2( FALSE, CatCompArray[ ASL_LOAD_WND ].cca_Str, FinestraPattern,
  1243.             ASL_LOAD_WND, WND_ext ))) {
  1244.     return( TRUE );
  1245.     }
  1246.  
  1247.     Stat( CatCompArray[ MSG_LOADING ].cca_Str, FALSE, 0 );
  1248.  
  1249.     do {
  1250.  
  1251.     LoaderBase = loader->LoaderBase;
  1252.  
  1253.     if( ret = LoadWindows( &IE, allpath2 )) {
  1254.         if( ret != LOADER_UNKNOWN ) {
  1255.         switch( ret ) {
  1256.             case LOADER_IOERR:
  1257.             Stat( CatCompArray[ ERR_IOERR ].cca_Str, TRUE, 0 );
  1258.             break;
  1259.  
  1260.             case LOADER_UNWELCOME:
  1261.             Stat( CatCompArray[ ERR_NOT_A_WND ].cca_Str, TRUE, 0 );
  1262.             break;
  1263.  
  1264.             case LOADER_WRONGVERSION:
  1265.             Stat( CatCompArray[ MSG_WRONG_VERSION ].cca_Str, TRUE, 0 );
  1266.             break;
  1267.  
  1268.             case LOADER_NOTSUPPORTED:
  1269.             ret2 = ret;
  1270.             break;
  1271.         }
  1272.         return( TRUE );
  1273.         }
  1274.     }
  1275.  
  1276.     loader = loader->Node.ln_Succ;
  1277.  
  1278.     } while(( ret == LOADER_UNKNOWN ) && ( loader->Node.ln_Succ ));
  1279.  
  1280.     if( ret != LOADER_OK ) {
  1281.     if( ret2 == LOADER_NOTSUPPORTED )
  1282.         Stat( CatCompArray[ ERR_NOT_SUPPORTED ].cca_Str, TRUE, 0 );
  1283.     else
  1284.         Stat( CatCompArray[ ERR_DATA_FORMAT ].cca_Str, TRUE, 0 );
  1285.     return( TRUE );
  1286.     }
  1287.  
  1288.     if( IE.num_win == 1 ) {
  1289.     for( cnt = 0; cnt < ATTIVA_CARICATA_NUM; cnt++ )
  1290.         OnMenu( BackWnd, attivamenu_nuovawin[ cnt ]);
  1291.     }
  1292.  
  1293.     Stat( CatCompArray[ MSG_WND_LOADED ].cca_Str, FALSE, 0 );
  1294.  
  1295.     return( TRUE );
  1296. }
  1297. ///
  1298. /// Carica Gadgets
  1299. BOOL CaricaGadMenued( void )
  1300. {
  1301.     struct LoaderNode  *loader;
  1302.     ULONG               ret, ret2 = 0L;
  1303.  
  1304.     loader = Loaders.mlh_Head;
  1305.  
  1306.     if(!( loader->Node.ln_Succ ))
  1307.     return( TRUE );
  1308.  
  1309.     if(!( GetFile2( FALSE, CatCompArray[ ASL_LOAD_GAD ].cca_Str, GadgetPattern,
  1310.             ASL_LOAD_GAD, GAD_ext ))) {
  1311.     return( TRUE );
  1312.     }
  1313.  
  1314.     Stat( CatCompArray[ MSG_LOADING ].cca_Str, FALSE, 0 );
  1315.  
  1316.     do {
  1317.  
  1318.     LoaderBase = loader->LoaderBase;
  1319.  
  1320.     if( ret = LoadGadgets( &IE, allpath2 )) {
  1321.         if( ret != LOADER_UNKNOWN ) {
  1322.         switch( ret ) {
  1323.             case LOADER_IOERR:
  1324.             Stat( CatCompArray[ ERR_IOERR ].cca_Str, TRUE, 0 );
  1325.             break;
  1326.  
  1327.             case LOADER_UNWELCOME:
  1328.             Stat( CatCompArray[ ERR_NO_GADGETS ].cca_Str, TRUE, 0 );
  1329.             break;
  1330.  
  1331.             case LOADER_WRONGVERSION:
  1332.             Stat( CatCompArray[ MSG_WRONG_VERSION ].cca_Str, TRUE, 0 );
  1333.             break;
  1334.  
  1335.             case LOADER_NOTSUPPORTED:
  1336.             ret2 = ret;
  1337.             break;
  1338.         }
  1339.         return( TRUE );
  1340.         }
  1341.     }
  1342.  
  1343.     loader = loader->Node.ln_Succ;
  1344.  
  1345.     } while(( ret == LOADER_UNKNOWN ) && ( loader->Node.ln_Succ ));
  1346.  
  1347.     if( ret != LOADER_OK ) {
  1348.     if( ret2 == LOADER_NOTSUPPORTED )
  1349.         Stat( CatCompArray[ ERR_NOT_SUPPORTED ].cca_Str, TRUE, 0 );
  1350.     else
  1351.         Stat( CatCompArray[ ERR_DATA_FORMAT ].cca_Str, TRUE, 0 );
  1352.     return( TRUE );
  1353.     }
  1354.  
  1355.     RifaiGadgets();
  1356.     RinfrescaFinestra();
  1357.  
  1358.     Stat( CatCompArray[ MSG_GAD_LOADED ].cca_Str, FALSE, 0 );
  1359.  
  1360.     if( IE.flags & NODISKFONT ) {
  1361.     IE.flags &= ~NODISKFONT;
  1362.     IERequest( CatCompArray[ MSG_NO_DISKFONT ].cca_Str, ok_txt, 0, 0 );
  1363.     }
  1364.  
  1365.     if( IE.flags & NO_IEX ) {
  1366.     IE.flags &= ~NO_IEX;
  1367.     IERequest( CatCompArray[ MSG_NO_IEX ].cca_Str, ok_txt,
  1368.            0, 0 );
  1369.     }
  1370.  
  1371.     return( TRUE );
  1372. }
  1373. ///
  1374. /// Carica Schermo
  1375. BOOL CaricaScrMenued( void )
  1376. {
  1377.     struct LoaderNode  *loader;
  1378.     ULONG               ret, ret2 = 0L;
  1379.  
  1380.     loader = Loaders.mlh_Head;
  1381.  
  1382.     if(!( loader->Node.ln_Succ ))
  1383.     return( TRUE );
  1384.  
  1385.     if (!( GetFile2( FALSE, CatCompArray[ ASL_LOAD_SCR ].cca_Str, ScrPattern, ASL_LOAD_SCR, "scr" )))
  1386.     return( TRUE );
  1387.  
  1388.     Stat( CatCompArray[ MSG_LOADING ].cca_Str, FALSE, 0 );
  1389.  
  1390.     do {
  1391.  
  1392.     LoaderBase = loader->LoaderBase;
  1393.  
  1394.     if( ret = LoadScreen( &IE, allpath )) {
  1395.         if( ret != LOADER_UNKNOWN ) {
  1396.         switch( ret ) {
  1397.             case LOADER_IOERR:
  1398.             Stat( CatCompArray[ ERR_IOERR ].cca_Str, TRUE, 0 );
  1399.             break;
  1400.  
  1401.             case LOADER_UNWELCOME:
  1402.             Stat( CatCompArray[ ERR_NO_SCR ].cca_Str, TRUE, 0 );
  1403.             break;
  1404.  
  1405.             case LOADER_WRONGVERSION:
  1406.             Stat( CatCompArray[ MSG_WRONG_VERSION ].cca_Str, TRUE, 0 );
  1407.             break;
  1408.  
  1409.             case LOADER_NOTSUPPORTED:
  1410.             ret2 = ret;
  1411.             break;
  1412.         }
  1413.         return( TRUE );
  1414.         }
  1415.     }
  1416.  
  1417.     loader = loader->Node.ln_Succ;
  1418.  
  1419.     } while(( ret == LOADER_UNKNOWN ) && ( loader->Node.ln_Succ ));
  1420.  
  1421.     if( ret != LOADER_OK ) {
  1422.     if( ret2 == LOADER_NOTSUPPORTED )
  1423.         Stat( CatCompArray[ ERR_NOT_SUPPORTED ].cca_Str, TRUE, 0 );
  1424.     else
  1425.         Stat( CatCompArray[ ERR_DATA_FORMAT ].cca_Str, TRUE, 0 );
  1426.     return( TRUE );
  1427.     }
  1428.  
  1429.     UpdateScr();
  1430.  
  1431.     return( TRUE );
  1432. }
  1433. ///
  1434.